﻿
Imports WillStrohl.Modules.QueryToGrid.SettingsInfoMembers

Namespace WillStrohl.Modules.QueryToGrid

    Public NotInheritable Class SettingsInfo
        Implements ISettingsInfo

#Region " Private Members "

        Private p_ModuleId As Integer = Null.NullInteger
        Private p_RecordsPerPage As Integer = Null.NullInteger

#End Region

#Region " Constructors "

        Public Sub New()
            ' do nothing
        End Sub

        Public Sub New(ByVal ModuleId As Integer, ByVal RecordsPerPage As Integer)
            Me.p_ModuleId = ModuleId
            Me.p_RecordsPerPage = RecordsPerPage
        End Sub

#End Region

#Region " Properties "

        Public Property ModuleId() As Integer Implements ISettingsInfo.ModuleId
            Get
                Return Me.p_ModuleId
            End Get
            Set(ByVal value As Integer)
                Me.p_ModuleId = value
            End Set
        End Property

        Public Property RecordsPerPage() As Integer Implements ISettingsInfo.RecordsPerPage
            Get
                Return Me.p_RecordsPerPage
            End Get
            Set(ByVal value As Integer)
                Me.p_RecordsPerPage = value
            End Set
        End Property

#End Region

        Public Sub Fill(ByVal dr As IDataReader)

            Try
                While dr.Read
                    If Not dr.Item(ModuleIdField) Is Nothing Then
                        Me.p_ModuleId = Integer.Parse(dr.Item(ModuleIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(RecordsPerPageField) Is Nothing Then
                        Me.p_RecordsPerPage = Integer.Parse(dr.Item(RecordsPerPageField).ToString, Globalization.NumberStyles.Integer)
                    End If
                End While
            Catch ex As Exception
                LogException(ex)
            Finally
                If Not dr.IsClosed Then
                    dr.Close()
                End If
            End Try

        End Sub

    End Class

End Namespace